//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Collections.Generic;
using System.IO;

namespace OpenLS.Spreadsheet.Formats.Biff.Records
{
    internal class ExtSstRecord : BiffRecord
    {
        private ushort dsst = 8;
        List<ISSTInf> ISSTInfs = new List<ISSTInf>();
        protected override void ReadContent(BiffReaderContext context, int length)
        {
            dsst = context.ReadUInt16();
            int count = (length - 2)/8;
            ISSTInfs = new List<ISSTInf>();
            for (int i = 0; i < count; i++)
            {
               ISSTInf ii = new ISSTInf();
                ii.Read(context.Reader);
                ISSTInfs.Add(ii);
            }

        }

        internal override BiffRecordType RecordType
        {
            get { return BiffRecordType.ExtSST; }
        }

        internal override void WriteContent(BiffWriterWorkbookContext context)
        {
            var writer = context.Writer;
            writer.Write(dsst);
            foreach (var item in this.ISSTInfs)
            {
                item.Write(writer);
            }
        }
    }
}
